Micron Document
🌎 rns.kin.earth git 🌍

Node / dev / reticulum / commits / 5de63d5

Commit 5de63d5bf2048847d28803ff00d23a93a8bdec14


Parents : c9d744f
Author : Mark Qvist <mark@unsigned.io>
Date : 2024-11-20T20:39:44+01:00

Internal interface config handling for TCPClientInterface

Changes

2 files changed, 19 insertions(+), 36 deletions(-)


Diff

diff --git a/RNS/Interfaces/TCPInterface.py b/RNS/Interfaces/TCPInterface.py
index a715ffe8..9b7c5f90 100644
--- a/RNS/Interfaces/TCPInterface.py
+++ b/RNS/Interfaces/TCPInterface.py
@@ -63,6 +63,7 @@ class ThreadingTCP6Server(socketserver.ThreadingMixIn, socketserver.TCPServer):
class TCPClientInterface(Interface):
BITRATE_GUESS = 10*1000*1000
+ DEFAULT_IFAC_SIZE = 16
RECONNECT_WAIT = 5
RECONNECT_MAX_TRIES = None
@@ -81,8 +82,19 @@ class TCPClientInterface(Interface):
I2P_PROBE_INTERVAL = 9
I2P_PROBES = 5
- def __init__(self, owner, name, target_ip=None, target_port=None, connected_socket=None, max_reconnect_tries=None, kiss_framing=False, i2p_tunneled = False, connect_timeout = None):
+ def __init__(self, owner, configuration, connected_socket=None):
super().__init__()
+
+ c = configuration
+ name = c["name"]
+ target_ip = c["target_host"]
+ target_port = int(c["target_port"])
+ kiss_framing = False
+ if "kiss_framing" in c and c.as_bool("kiss_framing") == True:
+ kiss_framing = True
+ i2p_tunneled = c.as_bool("i2p_tunneled") if "i2p_tunneled" in c else False
+ connect_timeout = c.as_int("connect_timeout") if "connect_timeout" in c else None
+ max_reconnect_tries = c.as_int("max_reconnect_tries") if "max_reconnect_tries" in c else None
self.HW_MTU = 1064
@@ -454,6 +466,8 @@ class TCPServerInterface(Interface):
# def __init__(self, owner, name, device=None, bindip=None, bindport=None, i2p_tunneled=False, prefer_ipv6=False):
def __init__(self, owner, configuration):
+ super().__init__()
+
c = configuration
name = c["name"]
device = c["device"] if "device" in c else None
@@ -466,8 +480,6 @@ class TCPServerInterface(Interface):
if port != None:
bindport = port
- super().__init__()
-
self.HW_MTU = 1064
self.online = False
@@ -529,8 +541,8 @@ class TCPServerInterface(Interface):
def incoming_connection(self, handler):
RNS.log("Accepting incoming TCP connection", RNS.LOG_VERBOSE)
- interface_name = "Client on "+self.name
- spawned_interface = TCPClientInterface(self.owner, interface_name, target_ip=None, target_port=None, connected_socket=handler.request, i2p_tunneled=self.i2p_tunneled)
+ spawned_configuration = {"name": "Client on "+self.name, "target_host": None, "target_port": None, "i2p_tunneled": self.i2p_tunneled}
+ spawned_interface = TCPClientInterface(self.owner, spawned_configuration, connected_socket=handler.request)
spawned_interface.OUT = self.OUT
spawned_interface.IN = self.IN
spawned_interface.target_ip = handler.client_address[0]

diff --git a/RNS/Reticulum.py b/RNS/Reticulum.py
index 9acfe97a..aabe76fa 100755
--- a/RNS/Reticulum.py
+++ b/RNS/Reticulum.py
@@ -594,41 +594,12 @@ class Reticulum:
interface_post_init(interface)
if c["type"] == "TCPClientInterface":
- kiss_framing = False
- if "kiss_framing" in c and c.as_bool("kiss_framing") == True:
- kiss_framing = True
- i2p_tunneled = c.as_bool("i2p_tunneled") if "i2p_tunneled" in c else False
- tcp_connect_timeout = c.as_int("connect_timeout") if "connect_timeout" in c else None
-
-
- interface = TCPInterface.TCPClientInterface(
- RNS.Transport,
- name,
- c["target_host"],
- int(c["target_port"]),
- kiss_framing = kiss_framing,
- i2p_tunneled = i2p_tunneled,
- connect_timeout = tcp_connect_timeout,
- )
-
- if "outgoing" in c and c.as_bool("outgoing") == False:
- interface.OUT = False
- else:
- interface.OUT = True
-
if interface_mode == Interface.Interface.MODE_ACCESS_POINT:
RNS.log(str(interface)+" does not support Access Point mode, reverting to default mode: Full", RNS.LOG_WARNING)
interface_mode = Interface.Interface.MODE_FULL
- interface.mode = interface_mode
-
- interface.announce_cap = announce_cap
- if configured_bitrate:
- interface.bitrate = configured_bitrate
- if ifac_size != None:
- interface.ifac_size = ifac_size
- else:
- interface.ifac_size = 16
+ interface = TCPInterface.TCPClientInterface(RNS.Transport, interface_config)
+ interface_post_init(interface)
if c["type"] == "I2PInterface":
i2p_peers = c.as_list("peers") if "peers" in c else None

Served by rngit 1.5.2 - Generated in 0.07s